\section*{\large Calibration}
\begin{normalsize}

The first step consists in calibrating the omnidirectional camera, which can be performed by means of the OCamCalib Toolbox for Matlab by D. Scaramuzza. This means detecting the center of the image and specifying internal and external boundaries of the omnidirectional image.

This is the procedure we followed:
%
\begin{enumerate}
	\item capture 6-10 chessboard images from all around the mirror approaching the chessboard to the mirror as much as possible and load them in ocam\_calib, see Figure \ref{fig:loadimage};
	\item extract grid corners individually and automatically, see Figure \ref{fig:corners};
	\item calibrate;
	\item find center;
	\item refine calibration;
	\item recompute corners;
	\item redo steps 2-3-4;
	\item save and export data.
\end{enumerate}
%
\begin{figure}[H]
\centering
\includegraphics[scale=0.3]{./images/loadimage.png}
\caption{chessboard images \label{fig:loadimage}}
\end{figure}	
%
\begin{figure}[H]
\centering
\includegraphics[scale=0.45]{./images/corners.png}
\caption{example of extracted grid corners \label{fig:corners}}
\end{figure}	

We got a good reprojection error of 0.266040 pixels. The calibration results are depicted in Figure \ref{fig:calibration_results}.

\begin{figure}[H]
\centering

	\begin{subfigure}[b]{0.4\textwidth}
		\includegraphics[width=\textwidth]{./images/calib_curves.png}
		\caption{plot of function F, and the plot of angle THETA of the corresponding 3D vector with respect to the horizon}
		\label{fig:calib_curves}
	\end{subfigure}

	\begin{subfigure}[b]{0.4\textwidth}
		\includegraphics[width=\textwidth]{./images/analyse_error.png}
		\caption{distribution of the reprojection error of each point for all the checkerboards}
		\label{fig:analyse_error}
	\end{subfigure}

	\begin{subfigure}[b]{0.4\textwidth}
		\includegraphics[width=\textwidth]{./images/extrinsic_params.png}
		\caption{position of every checkerboard with respect to the reference frame of the omnidirectional camera}
		\label{fig:extrinsic_params}
	\end{subfigure}

\caption{calibration results}
\label{fig:calibration_results}
\end{figure}

By clicking on the button Reproject on images, the Toolbox will reproject all grid corners according to the calibration parameters just estimated. The fact that the center of the image, indicated by the red round in Figure \ref{fig:center}, is not perfectly in the center will slightly effect the undistortion in a negative way.

\begin{figure}[H]
\centering
\includegraphics[scale=0.45]{./images/center.png}
\caption{camera center \label{fig:center}}
\end{figure}	

We report the content of the calibration generated file calibr\_results.txt, which can be read with the given C/C++ undistortion routines.

\begin{verbatim}
#polynomial coefficients for the DIRECT mapping function 
(ocam_model.ss in MATLAB).
These are used by cam2world

5 -8.968129e+01 0.000000e+00 2.625238e-03 1.516852e-06 -2.640204e-09 

#polynomial coefficients for the inverse mapping function 
(ocam_model.invpol in MATLAB).
These are used by world2cam

13 178.587796 174.634366 83.229331 58.030632 41.699337 31.144027 18.821422 
9.090172 12.921456 21.585120 18.136413 7.290121 1.140753 

#center: "row" and "column", starting from 0 (C convention)

249.650593 320.202173

#affine parameters "c", "d", "e"

1.000238 -0.000343 0.000088

#image size: "height" and "width"

480 640
\end{verbatim}

\end{normalsize}